<?php
	include 'ZionHeader.inc';
?>
<HTML>
<head>
<title>ZionsAuto</title>

	<?php
		$name = $_SESSION['UName'];
		$password = $_POST['password'];
		
		//Need to compare $name with username of announcement
	?>

  <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<BODY>
<h3>Notifications</h3>

<div>
<?php

	$AccountType = $_SESSION['AType'];
	include 'DatabaseConnect.inc';
	

	// fix notification to have seller ID, change bookmark to ahve announcement ID
	$queryNot = "SELECT * FROM Notification ORDER BY Timestamp Desc";
		
	$resultNot = mysql_query($queryNot);
	
	
	echo "<table border='1'>";
	echo "<tr>  <th>User</th> <th>Email</th> <th>Timestamp</th>  <th>VehicleID</th> <th>delete</th> ";

	echo "</tr>";
	// keeps getting the next row until there are no more to get
	while($rowNot = mysql_fetch_array( $resultNot, MYSQL_ASSOC )) {
		// Print out the contents of each row into a table
		
		$queryRegUser = "SELECT * FROM RegisteredUser WHERE RegisteredUserID = '".$rowNot['RegUserID']."' ";
		$resultRegUser = mysql_query($queryRegUser);
		$rowRegUser = mysql_fetch_array($resultRegUser);
		
		$queryAnn = "SELECT * FROM Announcement WHERE ID = '".$rowNot['AnnounceID']."' ";
		$resultAnn = mysql_query($queryAnn);
		$rowAnn = mysql_fetch_array($resultAnn);
		
		$queryUser = "SELECT * FROM User WHERE LoginID = '".$rowRegUser['LoginID']."' ";
		$resultUser = mysql_query($queryUser);
		$rowUser = mysql_fetch_array($resultUser);
		//echo "from ann ".$rowAnn['userID']." ";
		//echo "User ".$name."<br>";
		if (strtolower($name) == strtolower($rowAnn['userID']) ){
		echo "<tr><td>"; 
		echo $rowUser['LoginID'];
		echo "</td><td>"; 
		echo $rowUser['Email'];
		echo "</td><td>"; 
		echo $rowNot['Timestamp'];
		echo "</td><td>"; 
		echo $rowNot['VehicleID'];
		echo "</td><td>"; 
		echo "<form action='DeleteNotification.php' method ='POST'>";
		echo "    <input type='hidden' name='ID' value = '".$rowNot['ID']."' />";
		echo "    <input type='submit' name='Submit' value ='Delete'/>";
		echo "</form>";

		echo "</td></tr>"; 
		}
	} 

	echo "</table>";

	
	mysql_close();
?>
</div>

</BODY>
</HTML>